<?php
namespace app\admin\controller;
use think\Controller;
use app\admin\Model\Status as Sta;
use app\admin\Model\Pay;
use app\admin\Model\Number;
class Status extends Common{
	public function list(){
		$list = Sta::with('number')->with('rom,pay')->paginate(4);
		
		$page = $list->render();
	  //halt($list);
		
		return $this->fetch('list',['list'=>$list,'page'=>$page]);
	}
	public function add(){
		
		$sta = new Sta();
		if(input("?param.sub")){
			$result = $sta->add();
			
			if($result){
				$this->success("添加成功","status/list");
			}else{
				$this->error("添加失败");
			}
		}else{
			//$data  = \app\index\model\Class1::getList();
			$pay = new Pay();
			$list1 = Pay::all();
			//halt($list1);
			$num = new Number();
			$list = Number::all();
			$this->assign('list1',$list1);
			$this->assign('list',$list);
			return $this->fetch();
		}
	}
	
	public function update(){
		$sta = new Sta();
		
		if(input("?param.sub")){
			
			$result = $sta->upd();
			
			if($result){
				$this->success("修改成功","index/list");
			}else{
				$this->error("修改失败");
			}
		}else{
			$pay = new Pay();
			$list1 = Pay::all();
			$num = new Number();
			$list = Number::all();
			
			$id = input('param.s_id');
    	
    	$data = Sta::get($id);
    	
    	$this->assign('list1',$list1);
    	$this->assign('data',$data);
    	$this->assign('list',$list);
        return $this->fetch();
		}
	}
}
?>